﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ArticleManagementSystem
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Unnamed_LoggingIn(object sender, LoginCancelEventArgs e)
        {
            var uid = Login1.UserName.Trim();
            var pwd = Login1.Password.Trim();
            string sql = string.Format("select * from Users where Username='{0}' and Password='{1}'", uid, pwd);
            var a = DbHelp.dataTable(sql);
            var check = a.Rows[0];
            var isActived = (bool)check.ItemArray[3];
            var isDeleted = (bool)check.ItemArray[4];
            if (a.Rows.Count == 1)
            {
                if (isActived)
                {
                    if (!isDeleted)
                    {
                        Response.Redirect("Default.aspx");
                    }
                    else {
                        Label1.Text = "此账号已被删除或注销";
                    }

                }
                else  {
                    Label1.Text = "此账号已被停用，请联系客服";
                }
            }
            else
            {
                Label1.Text = "用户名或密码错误";
            }
        }
    }
}